// 如果没有通过拦截器配置域名的话，可以在这里写上完整的URL(加上域名部分)

// 此处第二个参数vm，就是我们在页面使用的this，你可以通过vm获取vuex等操作，更多内容详见uView对拦截器的介绍部分：
// https://uviewui.com/js/http.html#%E4%BD%95%E8%B0%93%E8%AF%B7%E6%B1%82%E6%8B%A6%E6%88%AA%EF%BC%9F
const install = (Vue, vm) => {
	// 登录
	let getLogin = (params = {}) => vm.$u.post('/api/v1/auth/login', params);
	// 注册
	let getRegister = (params = {}) => vm.$u.post('/api/v1/auth/register', params);
	// 根据手机号查找用户
	let searchUser = (params = {}) => vm.$u.get('/api/v1/user/search', params);
	// 获得个人信息
	let userInfo = (params = {}) => vm.$u.get('/api/v1/user/info', params);
	// 修改个人信息
	let userModify = (params = {}) => vm.$u.put('/api/v1/user/modify', params);
	// 退出
	let logout = (params = {}) => vm.$u.get('/api/v1/user/logout', params);
	// 添加好友
	let addFriend = (params = {}) => vm.$u.post('/api/v1/contact/addFriend', params);
	// 好友列表
	let friendsList = (params = {}) => vm.$u.get('/api/v1/contact/friendsList', params);
	// 是否好友
	let isFriend = (params = {}) => vm.$u.get('/api/v1/contact/isFriend', params);
	// 实时消息
	let realTimeMessage = (params = {}) => vm.$u.get('/api/v1/message', params);
	// 历史记录
	let historyRecord = (params = {}) => vm.$u.get('/api/v1/message/historyRecord', params);
	// 将消息设为已读
	let makeMessageRead = (params = {}) => vm.$u.post('/api/v1/message/makeRead', params);
	// 创建群聊
	let createCommunity = (params = {}) => vm.$u.post('/api/v1/community', params);
	// 加入群聊
	let joinCommunity = (params = {}) => vm.$u.post('/api/v1/community/join', params);
	// 群聊列表
	let communityList = (params = {}) => vm.$u.get('/api/v1/community/list', params);
	// 群成员列表
	let memberList = (params = {}) => vm.$u.get('/api/v1/community/members', params);
	// 群聊信息
	let communityInfo = (params = {}) => vm.$u.get('/api/v1/community', params);
	
	// 将各个定义的接口名称，统一放进对象挂载到vm.$u.api(因为vm就是this，也即this.$u.api)下
	vm.$u.api = {getLogin, getRegister, searchUser, userInfo, userModify, logout, addFriend, friendsList, isFriend, realTimeMessage, historyRecord, makeMessageRead, createCommunity, joinCommunity, communityList, memberList, communityInfo};
}

export default {
	install
}